/**
 * Copyright 2014 ABSir's Studio
 * 
 * All right reserved
 *
 * Create on 2014-2-17 下午4:06:43
 */
package com.absir.server.socket;

import java.nio.channels.SocketChannel;

import com.absir.server.in.InModel;
import com.absir.server.socket.SocketServerContext.ChannelResolver;
import com.absir.server.socket.resolver.SocketChannelResolver;

/**
 * @author absir
 * 
 */
public class InputSocketImpl extends InputSocket {

	/**
	 * @param model
	 * @param inputSocketAtt
	 * @param socketChannel
	 */
	public InputSocketImpl(InModel model, InputSocketAtt inputSocketAtt, SocketChannel socketChannel) {
		super(model, inputSocketAtt, socketChannel);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.absir.server.socket.InputSocket#getSocketChannelResolver()
	 */
	@Override
	public SocketChannelResolver getSocketChannelResolver() {
		return ChannelResolver.ME;
	}

	/**
	 * @param socketChannel
	 * @param bytes
	 * @return
	 */
	public static boolean writeByteBuffer(SocketChannel socketChannel, byte[] bytes) {
		return writeByteBuffer(ChannelResolver.ME, socketChannel, bytes);
	}

	/**
	 * @param socketChannel
	 * @param callbackIndex
	 * @param bytes
	 * @return
	 */
	public static boolean writeByteBuffer(SocketChannel socketChannel, int callbackIndex, byte[] bytes) {
		return writeByteBuffer(socketChannel, (byte) 0, callbackIndex, bytes);
	}

	/**
	 * @param socketChannel
	 * @param flag
	 * @param callbackIndex
	 * @param bytes
	 * @return
	 */
	public static boolean writeByteBuffer(SocketChannel socketChannel, byte flag, int callbackIndex, byte[] bytes) {
		return writeByteBuffer(ChannelResolver.ME, socketChannel, flag, callbackIndex, bytes);
	}

	/**
	 * @param socketChannel
	 * @param success
	 * @param callbackIndex
	 * @param bytes
	 * @return
	 */
	public static boolean writeByteBufferSuccess(SocketChannel socketChannel, boolean success, int callbackIndex, byte[] bytes) {
		return writeByteBufferSuccess(ChannelResolver.ME, socketChannel, success, callbackIndex, bytes);
	}
}
